import { IsIn, IsNotEmpty, ValidateIf } from 'class-validator';

export class LoginUserDto {
  @IsNotEmpty({ message: '用户名不能为空' })
  username: string;

  @ValidateIf((o) => o.type === 'password')
  @IsNotEmpty({ message: '密码不能为空' })
  password: string;

  @ValidateIf((o) => o.type === 'captcha')
  @IsNotEmpty({ message: '验证码不能为空' })
  captcha: string;

  @IsIn(['password', 'captcha'])
  type: 'password' | 'captcha';
}
